<?php
namespace jy_newczfee;
defined('BY_JYA') or exit('error');
/*
	任务
*/
class task extends \plugin{
	//加权代理
	public function up_fee2($setting=array()){
		if($setting){
			$this->setting=$setting;
		}
		$month=date('Y-m');
		$monthtime=strtotime($month);
		$isfeelog=pdo_get('jy_newczfee_feelog',array('type'=>2,'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$monthtime));
        if($isfeelog['id']){
            return false;
        }
        $orders=pdo_getall('jy_newczfee_order',array('monthfee >'=>0,'lastmonth >'=>0,'uniacid'=>$_SESSION['uniacid']));
        $log['num']=count($orders);
        if(!$log['num']){
            continue;
        }
        foreach($orders as $mv){
			$feelog=array(
				'uniacid'=>$_SESSION['uniacid'],
				'mid'=>$mv['mid'],
				'orderid'=>$mv['orderid'],
				'levelid'=>$mv['levelid'],
				'fee'=>$mv['monthfee'],
				'month'=>$month,
				'status'=>2,
				'type'=>2,
				'createtime'=>TIMESTAMP,
			);
			pdo_insert('jy_newczfee_feelog',$feelog);
			model('core/member')->member_credit($feelog['mid'],'credit3',$feelog['fee'],true,'jy_newczfee','充值每月返金币');
			pdo_update('jy_newczfee_order',array('lastmonth -='=>1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$mv['id']));
		}
		return true;
	}
}